package cn.lxh.test;


import cn.hutool.core.bean.BeanUtil;
import cn.lxh.StartApp;
import cn.lxh.basic.utils.DateUtil;
import cn.lxh.basic.utils.PageList;
import cn.lxh.org.domain.Department;
import cn.lxh.org.domain.DictionaryDetail;
import cn.lxh.org.domain.DictionaryType;
import cn.lxh.org.domain.Employee;
import cn.lxh.org.mapper.DepartmentMapper;
import cn.lxh.org.mapper.EmployeeMapper;
import cn.lxh.org.query.DictionaryDetailQuery;
import cn.lxh.org.query.DictionaryTypeQuery;
import cn.lxh.org.query.ShopQuery;
import cn.lxh.org.service.IDepartmentService;
import cn.lxh.org.service.IDictionaryDetailService;
import cn.lxh.org.service.IDictionaryTypeService;
import cn.lxh.org.service.IEmployeeService;
import cn.lxh.org.service.IShopAuditLogService;
import cn.lxh.org.service.IShopService;
import cn.lxh.user.domain.WxPublicContent;
import cn.lxh.user.mapper.WxPublicTouserMappper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;
import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = StartApp.class)
public class Mytest {
    @Autowired
    private DepartmentMapper departmentMapper;
    @Autowired
    private IDepartmentService iDepartmentService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private WxPublicTouserMappper wxPublicTouserMappper;

    @Test
    public void test01(){

        System.out.println("nacos配置");
    }

    /**
     * 根据id查询
     */
    @Test
    public void test02(){
        String templateId = "E5Tl-WGxsBYETE8S98s784bT8AW4r9JoMt15m4uxa_Y";
        String touser = "oaFOT6nSaeDkYcjLCZ4JazYIs0IM";
        WxPublicContent wxPublicContentTem =wxPublicTouserMappper.selectContentByTemUser(templateId,touser);
        Map<String, Object> stringObjectMap = BeanUtil.beanToMap(wxPublicContentTem);

        System.out.println(stringObjectMap);
    }
    /**
     * 新增
     */
    @Test
    public void test03(){
      /*  Department department = new Department(null, "大", "小", "dad", 3, 4l, 6l, 2l);
        iDepartmentService.save(department);*/
    }

    /**
     * 更新
     */
    @Test
    public void test04(){
        Department department = new Department();
        iDepartmentService.update(department);
        iDepartmentService.queryAll().forEach(System.out::println);
    }
    /**
     * 删除
     */
    @Test
    public void test05(){
        iDepartmentService.delete(64l);
        iDepartmentService.queryAll().forEach(System.out::println);
    }
    /**
     * 分页功能
     */


    /**
     * 批量删除
     */
    @Test
    public void test07(){
        Long [] ids ={55l,56l};
        iDepartmentService.batchReove(ids);
        iDepartmentService.queryAll().forEach(System.out::println);
    }

    /**
     * 员工表 全部查询
     */
    @Autowired
    private IEmployeeService employeeService;
    @Test
    public void test08(){
        employeeService.queryAll().forEach(System.out::println);
    }

    /**
     * 无限极数测试
     */
    @Test
    public void test10(){
        Employee employee = new Employee(345l, "zhangsa", "322", "3223", "agag", "1", 12, 1, 2l, 3l, 5l);
        employeeService.save(employee);
        employeeService.queryAll().forEach(System.out::println);
    }

    @Test
    public void test11(){
        Employee employee = new Employee(345l, "zhangsa", "322", "3223", "agag", "1", 12, 1, 2l, 3l, 5l);
        employeeService.update(employee);
        employeeService.queryAll().forEach(System.out::println);
    }

    /**
     * 字典 类型查询  全部
     */
    @Autowired
    private IDictionaryTypeService dictionaryTypeService;
    @Test
    public void test12(){
        dictionaryTypeService.queryAll().forEach(System.out::println);
    }
    /*分页功能*/
    @Test
    public void test13(){
        DictionaryTypeQuery dictionaryTypeQuery = new DictionaryTypeQuery();
        dictionaryTypeService.queryList(dictionaryTypeQuery);

    }
    /*新增功能*/

    @Test
    public void test14(){
        DictionaryType dictionaryType = new DictionaryType(null, "张9", "张四");
        dictionaryTypeService.save(dictionaryType);
        dictionaryTypeService.queryAll().forEach(System.out::println);
    }

    /**
     * 修改
     */
    @Test
    public void test15(){
        DictionaryType dictionaryType = new DictionaryType(3l, "张5", "张四");
        dictionaryTypeService.update(dictionaryType);
        dictionaryTypeService.queryAll().forEach(System.out::println);
    }

    /**
     * 删除
     */
    @Test
    public void test16(){
        dictionaryTypeService.delete(3l);
        dictionaryTypeService.queryAll().forEach(System.out::println);
    }

    /**
     * 细节 字典
     */
    @Autowired
    private IDictionaryDetailService dictionaryDetailService;
    @Test
    public void test21(){
        dictionaryDetailService.queryAll().forEach(System.out::println);
    }

    @Test
    public void test22(){
        DictionaryTypeQuery dictionaryTypeQuery = new DictionaryTypeQuery();
        dictionaryDetailService.queryList(dictionaryTypeQuery);
    }

    /**
     * 修改
     */
    @Test
    public void test23(){
        DictionaryDetail dictionaryDetail = new DictionaryDetail(7l, "张55", 33l);
        dictionaryDetailService.update(dictionaryDetail);
        dictionaryDetailService.queryAll().forEach(System.out::println);
    }

    /**
     * 增加
     */
    @Test
    public void test24(){
        DictionaryDetail dictionaryDetail = new DictionaryDetail(5l, "张5", 3l);
        dictionaryDetailService.save(dictionaryDetail);
        dictionaryDetailService.queryAll().forEach(System.out::println);
    }

    /**
     * 删除
     */
    @Test
    public void test25(){
        dictionaryDetailService.delete(5l);
        dictionaryDetailService.queryAll().forEach(System.out::println);
    }

    /*分页功能*/
    @Test
    public void test26(){
        DictionaryDetailQuery dictionaryDetailQuery = new DictionaryDetailQuery();
        dictionaryTypeService.queryList(dictionaryDetailQuery);

    }
    @Autowired
    private EmployeeMapper employeeMapper;
    @Test
    public void test31(){
        System.out.println(employeeMapper.findByUsername("335"));
    }

    @Test
    public void test32(){
        Employee employee = new Employee(null, "3", "1@qq.com", "23", "2", "3", 3, 1, 322l, 3223l, 32l);
        employeeMapper.save(employee);
    }

    /**
     * shop的分页查询
     *
     */
    @Autowired
    private IShopService shopService;
    @Test
    public void test41(){
        ShopQuery shopQuery = new ShopQuery();
        PageList list = shopService.queryList(shopQuery);
        System.out.println(list);
    }
    @Autowired
    private IShopAuditLogService shopAuditLogService;

    /**
     * 日志的单独查询
     */
    @Test
    public void test42(){
        String time = "2016-12-11 20:39:24";

        Date date = DateUtil.convertStrToDate(time);

        int loveDay = DateUtil.differentDaysByMillisecond( date,new Date());

        System.out.println(new Date(2016, 12, 11));
        System.out.println(new Date(2023, 07, 20, 12, 12, 20));
        System.out.println(new Date());
        System.out.println(loveDay);
    }



}
